<?php
    include("../include/toppage.inc");
    include("../include/header.inc");
    include("../../BusinessObject/personne.php");
    include("../../include/fonctions.inc.php");
    
    $personne = new personne();
    
    if(isset($_GET['id'])){
        $personne->id = $_GET['id'];
        $personne->getDetailPersonne();
    }
    else{
        $personne->id = $_POST['id'];
        
        $personne->nom = $_POST['nom'];
        $personne->prenom = $_POST['prenom'];
        $personne->adresse = $_POST['adresse'];
        $personne->npa = $_POST['npa'];
        $personne->localite = $_POST['localite'];
        $personne->email = $_POST['email'];
        $personne->telephone = $_POST['telephone'];
        $personne->portable = $_POST['portable'];
        
        $personne->modifParticipant();
    } 
    
?>

<script>
function suppressionParticipant(id){
    if(confirm("Voulez-vous vraiment supprimer ce participant?")){
        document.location = 'SuppressionParticipant.php?id=' + id;
    }
}


</script>

<div id="main">
    <h1>Modification des informations d'un participant</h1>
    
    <form method="post" action="ModifParticipant.php">
        
        <input type="hidden" name="id" value="<?php echo $personne->id; ?>" />
        
        <span class="label">Nom *:</span>
        <span class="champ"><input type="text" name="nom" id="nom" value="<?PHP echo $personne->nom; ?>" /></span>
        
        <span class="label_2">Prénom *:</span>
        <span class="champ_2"><input type="text" name="prenom" id="prenom" value="<?php echo $personne->prenom; ?>" /><br /></span>
        
        <span class="label">Adresse :</span>
        <span class="champ"><input type="text" name="adresse" id="adresse" size="50" value="<?PHP echo $personne->adresse; ?>" /></span><br />
        
        <span class="label">NPA :</span>
        <span class="champ"><input type="text" name="npa" id="npa" value="<?PHP echo $personne->npa; ?>" /></span>
        
        <span class="label_2">Localité :</span>
        <span class="champ_2"><input type="text" name="localite" id="localite" value="<?php echo $personne->localite; ?>" /><br /></span>
        
        <span class="label">Email :</span>
        <span class="champ"><input type="text" name="email" id="email" size="50" value="<?PHP echo $personne->email; ?>" readonly/></span><br />
        
        <span class="label">Téléphone :</span>
        <span class="champ"><input type="text" name="telephone" id="telephone" value="<?PHP echo $personne->telephone; ?>"/></span>
        
        <span class="label_2">Portable :</span>
        <span class="champ_2"><input type="text" name="portable" id="portable" value="<?php echo $personne->portable; ?>" /><br /></span>
        
        <span class=""><input type="submit" value="Mettre à jour" /></span>
        
    </form>
    <button onclick="javascript:suppressionParticipant(<?php echo $personne->id; ?>);">Supprimer</button>
    <button onclick="parent.location='GestionMembres.php'">Annuler</button>
    
</div>

<?php
    include("../include/footer.inc");
?>